const state = () => ({
  list: [{ id: 1 }, { id: 2 }, { id: 3 }]
})

const mutations = {
  // 同步操作list
  SET_LIST(state, list) {
    state.list = list
  }
}

const actions = {
  // 异步操作list
  async setList({ commit }) {
    return await new Promise((resolve, reject) => {
      setTimeout(() => {
        commit('SET_LIST', [{ id: 1 }, { id: 3 }, { id: 5 }])
        resolve()
      }, 1e3)
    })
  }
}

export default {
  namespaced: true, // 开启命名空间
  state,
  mutations,
  actions
}
